import { reqGetTradeListData } from '@/api';
const state = {
  tradeInfo: {}
};
const actions = {
  // 获取结算页数据请求
  async getTradeListDataActions({ commit }) {
    const result = await reqGetTradeListData();
    if (result.code === 200) {
      commit('SAVE_TRADE_LIST_DATA', result.data);
    } else {
      console.log(result.message);
    }
  }
};
const mutations = {
  // 存储结算页数据
  SAVE_TRADE_LIST_DATA(state, payload) {
    console.log(payload, '结算界面');
    state.tradeInfo = payload;
  }
};
const getters = {
  // 商品数量
  totalNum(state) {
    return state.tradeInfo.totalNum;
  },
  // 订单编号
  tradeNo(state) {
    return state.tradeInfo.tradeNo;
  },
  // 实付总金额
  totalAmount(state) {
    return state.tradeInfo.totalAmount;
  },
  // 原始商品总金额 服务器端直接响应回来的数据金额 不加优惠券 不加邮费
  originalTotalAmount(state) {
    return state.tradeInfo.originalTotalAmount;
  },

  // 商品详情列表
  detailArrayList(state) {
    return state.tradeInfo.detailArrayList;
  }
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
};
